package com.lesama.array2;

import java.util.Random;

public class ArrayDemo2 {
    public static void main(String[] args) {
        int[][] arr = new int[5][4];
        Random r = new Random();
        for (int i = 0; i < arr.length; i++) {
            for (int j = 0; j < arr[i].length; j++) {
                arr[i][j] = r.nextInt(100);
                System.out.print(arr[i][j] + " ");
            }
            System.out.println();
        }
        System.out.println(getSumFromArray(arr));
    }
    public static int getSumFromArray(int[][] arr) {
        int sum = 0;
        for (int i = 0; i < arr.length; i++) {
            for (int j = 0; j < arr[i].length; j++) {
                sum += arr[i][j];
            }
        }
        return sum;
    }
}
